[DX-1285] Implement get-message to retrieve latest version by serial#385
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Adds a new channels get-message command to the Ably CLI to retrieve the latest version of a mutable message by its serial, aligning JSON and human output formats with existing channel message commands.
Changes:
- Introduces
ably channels get-message <channel> <serial>implemented via Ably RESTchannel.getMessage(), with optional--ciphersupport. - Adds unit tests validating SDK invocation, JSON envelope/shape (including timestamp normalization), human-readable formatting, and error surfacing.
- Extends E2E mutable-message test coverage to include get-message behavior (basic retrieval, post-update latest version, human output, and unknown-serial failure).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/commands/channels/get-message.ts |
Implements the new channels get-message command, including JSON and human-readable output paths. |
test/unit/commands/channels/get-message.test.ts |
Adds unit coverage for argument/flag handling, output shape/format, and error propagation. |
test/helpers/mock-ably-rest.ts |
Extends the REST channel mock with a getMessage method and representative message payload. |
test/e2e/channels/channel-message-ops-e2e.test.ts |
Adds E2E coverage for message retrieval and latest-version semantics after updates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
WalkthroughAdds Changes
Review Notes
|
get-message to retrieve latest version by serialget-message to retrieve latest version by serial
b38c16e to
b296802
Compare
| import type { MessageDisplayFields } from "../../utils/output.js"; | ||
|
|
||
| const MUTABLE_MESSAGES_HINT = | ||
| "The channel may not have mutableMessages enabled — without this rule, individual messages cannot be retrieved by serial. Please check the same using 'ably apps rules list'. If the 'Mutable Messages' rule is enabled, then make sure to enter correct message serial."; |
There was a problem hiding this comment.
| "The channel may not have mutableMessages enabled — without this rule, individual messages cannot be retrieved by serial. Please check the same using 'ably apps rules list'. If the 'Mutable Messages' rule is enabled, then make sure to enter correct message serial."; | |
| "Ensure the channel has a `mutableMessages` rule enabled (run `ably apps rules list`) and that the message serial is correct."; |
|
I've pulled this down and tested locally. The error hint is not showing in the expected |
eea83ba to
4a09e0f
Compare
Fixed at 65d2c0e |
- Stringify `action` in JSON output for predictable typing across commands (matches `channels subscribe`'s normalisation; our trace payload and human display already do this). - Use a nullish check on `timestamp` so a legitimate epoch-zero value is preserved as `1970-01-01T00:00:00.000Z` instead of being dropped to `undefined`. (Note: same pattern exists in `channels history`; fixing there is out of scope for this PR.) - Update the in-code comment to drop the inaccurate "strict superset of subscribe" claim — JSON shape mirrors `channels history`'s raw SDK spread, which is the right precedent for one-shot REST queries. - Add unit tests for both the epoch-zero timestamp path and the `action` stringification. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…to fail method, accordingly recording error for the same
4a09e0f to
65d2c0e
Compare
ably channels get-message CHANNEL_NAME MESSAGE_SERIAL— wraps the Ably REST SDK'schannel.getMessage()to fetch the latest version of a single message by its serial.get-messageis singular and explicit about operation.kabab-casefollows existing conventions, e.g. ably push config set-apnsannotations summaryfor returnedmsg-serial, currently there's no way to displayannotation summaryfor givenmsg-serial.channels history's per-element shape (raw SDK message spread, ISO-normalised timestamp, stringifiedaction) — the right precedent for a one-shot REST query. Human output reuses the sharedformatMessagesOutputformatter, so the same record renders identically acrossget-message,history, andsubscribe.